package gdma.hqdes.bean;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Author wangyue
 * @Version 3.0
 * @Date 2024-07-30
 */

@Data
public class UnitStat extends Unit implements Stat {

    @TableField(exist = false)
    List<UnitScore> scores;

    @Override
    public String toShortString() {
        return shortName;
    }

    @JsonIgnore
    public Map<Long, UnitScore> getScoreMap() {
        if(scores == null) return null;
        return scores.stream().collect(Collectors.toMap(UnitScore::getIndexId, n -> n));
    }

}
